package com.ricardoteix.subtitle {
	/**
	 * ...
	 * @author Ricardo Teixeira
	 */
	public class SubtitleTime {
		
		private var _date:Date;
		
		private var subTimestamp:String;
		
		public function SubtitleTime (subTimestamp:String) {
			this.subTimestamp = subTimestamp;			
			this.parseTimestamp ();
		}
		
		private function parseTimestamp():void {
			var subLine:String = this.subTimestamp.replace (" ", "");
			subLine = escape (subLine).replace ("%0D", "");
			subLine = unescape (subLine);
			subLine = subLine.replace ("\t", "");
			subLine = subLine.replace ("\r", "");
			subLine = subLine.replace ("\n", "");
			
			var timeParts:Array = subLine.split (/(\d{2}):(\d{2}):(\d{2})[,|:|.](\d*)/);
			timeParts.splice (0, 1);
			timeParts.splice (timeParts.length - 1, 1);
			
			this._date = new Date (0, 0, 0, timeParts[0], timeParts[1], timeParts[2], timeParts[3]);	
		}
		
		public function get date():Date { return _date; }
		
		public function toString ():String {
			return this.subTimestamp;
		}
		
	}

}